package zuoye.zuoye1;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Test {
    public static void main(String[] args) {
        Collection<String> c = new ArrayList<>();
        c.add("Java企业级开发指南");
        c.add("Oracle高级编程");
        c.add("MySQL从入门到精髓");
        c.add("Java架构师之路");
        extracted(c);
        System.out.println("===========");
        itratate( c);
        System.out.println("===========");
        javas( c);
        System.out.println("===========");
        rameos( c);



    }

    private static void extracted(Collection<String> c) {
        System.out.println("--所有元素如下---");
        Iterator<String> it = c.iterator();
        while (it.hasNext()) {
            String book = it.next();
            System.out.println(book);
        }
    }

    public static void itratate(Collection<String> c) {
        System.out.println("--书名小于10个字符元素如下---");
        Iterator<String> it = c.iterator();
        while (it.hasNext()) {
            String book = it.next();
            if (book.length() < 10) {
                System.out.println(book);
            }
        }
    }

    public static void javas(Collection<String> c){
        System.out.println("--包含java元素如下---");
        Iterator<String> it = c.iterator();
        while (it.hasNext()) {
            String book = it.next();
            if (book.contains("Java")){
                System.out.println(book);
            }
        }
    }

    public static void rameos(Collection<String> c){
        System.out.println("--删除Oracle元素如下---");
        Iterator<String> it = c.iterator();
        while (it.hasNext()) {
            String book = it.next();
            if (book.contains("Oracle高级编程")){
                it.remove();
            }
        }
        System.out.println("--删除Oracle元素后---");
        for (String book : c) {
            System.out.println(book);
        }
    }


}
